import Fetch from "ahooks/lib/useRequest/src/Fetch";
import FetchHelper from "../helper/fetch-helper";
import { geomToWkt } from "../helper/mapHelper";
import _ from 'lodash';

export default class YhdApi{
    static async listByPolygon(polygon){
        let wkt=polygon
        if(!_.isString(polygon)){
            wkt=geomToWkt(wkt);
        }
        const resp=await FetchHelper.getJson(`/admin-api//ybyj/yhsj/selectByYhlxAndWkt`,{
            wkt:wkt
        })
        return resp;
        // resp.data=resp.data?.map(item=>{
        //     return {
                
        //     }
        // })
    }
    static async yhdxq(yhlx,polygon){
        let wkt=polygon;
        if(!_.isString(polygon)){
            wkt=geomToWkt(wkt);
        }
       
        const resp=await FetchHelper.getJson(`/admin-api//ybyj/yhsj/selectByYhlxAndWkt`,{
            yhlx:yhlx,
            wkt:wkt
        })
        resp.data=resp.data.map(item=>{
            return {
                title:item?.yhmc,
                id:item?.id,
                xq:item?.xq
            }
        })
        return resp;
    }
    static async listId(id){
        try{
            const resp=await FetchHelper.getJson(`/admin-api/ybyj/yhsj/list`,{
                id:id,
            })
            return resp;
        }catch(err){
            return {rows:[]}
        }
    }
}